// 定义记分牌的类
class ScorePanel {
    // 分数和等级
    score = 0
    level = 1
    scoreEle: HTMLElement
    levelEle: HTMLElement

    // 设置一个变量限制等级
    maxLevel: number
    // 表示多少分时升级
    upScore: number



    constructor(maxLevel: number = 10, upScore: number = 3) {
        this.scoreEle = document.querySelector('#score')!
        this.levelEle = document.querySelector('#level')!
        this.maxLevel = maxLevel
        this.upScore = upScore
    }

    // 加分方法
    addScore() {
        this.scoreEle.innerHTML = ++this.score + ''
        if (this.score % this.upScore === 0) {
            // console.log(this.score);
            this.levelUp()
        }
    }
    levelUp() {
        if (this.level < this.maxLevel) {
            this.levelEle.innerHTML = ++this.level + ''
        }
    }
}

export default ScorePanel